<?php

namespace App\Modules\Setting;

use App\Modules\AdapterApi;
use App\Services\Setting\SettingIndex;

/**
 * 系统设置
 * Class Setting
 * @package App\Modules\Setting
 */
class Setting extends AdapterApi
{

    //获取车辆信息筛选项
    public function getSelection()
    {
        $data['action'] = 'select';
        $res = SettingIndex::SettingCategory()->getSelection($data);
        return auto_return($res);
    }

    /**
     * 编辑一个配置
     * @return array
     */
    public function editSet(): array
    {
        $data = pick_array($this->postData, ['id', 'category_id', 'name', 'value', 'action', 'type', 'order', 'other_info']);

        return SettingIndex::Setting()->editSet($data);
    }

    public function editSetting()
    {
        $data = pick_array($this->postData, ['id', 'name', 'value', 'action', 'token']);
        return SettingIndex::Setting()->editSetting($data);
    }

    public function getSettingList()
    {
        $data = pick_array($this->postData, ['page', 'keywords']);
        return SettingIndex::Setting()->getSettingList($data);
    }

    /**
     * 获取某个具体配置
     * @return array
     */
    public function getOneSet(): array
    {
        $data = pick_array($this->postData, ['id', 'token']);

        return SettingIndex::Setting()->getOneSet($data);
    }
    /**
     * 获取本应用配置列表
     * @return array
     */
    public function getAppSet(): array
    {
        $data = pick_array($this->postData, ['page', 'listRows', 'token'], false);

        return SettingIndex::Setting()->getAppSet($data);
    }
    /**
     * 添加一个具体配置
     * @return array
     */
    public function addSet()
    {
        $data = pick_array($this->postData, ['category_id','name','value','action','type','order','other_info','token']);

        return SettingIndex::Setting()->addSet($data);
    }
}
